//
//  ProductEditRightArrowCell.m
//  AFNetworking
//
//  Created by admin on 2020/4/28.
//

#import "ProductEditRightArrowCell.h"

@implementation ProductEditRightArrowCell


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self configUI];
        
    }
    return self;
}
-(void)configUI{
    
    [self.contentView addSubview:self.titleLab];
    [self.contentView addSubview:self.titleLab];
    [self.contentView addSubview:self.rightArrow];
    [self.contentView addSubview:self.valueLab];
    
}

-(UILabel *)titleLab{
    if (!_titleLab) {
        _titleLab = [UILabel new];
        _titleLab.font = FONT_SYS14;
        _titleLab.textColor = COLOR_33;
    }
    return _titleLab;
}

-(UIImageView *)notNullIcon{
    if (!_notNullIcon) {
        _notNullIcon = [UIImageView new];
    }
    return _notNullIcon;
}

-(UIImageView *)rightArrow{
    if (!_rightArrow) {
        _rightArrow = [UIImageView new];
        [_rightArrow setImage:[UIImage imageWithIcon:@"fa-angle-right" backgroundColor:[UIColor clearColor] iconColor:COLOR_99 andSize:CGSizeMake(18, 18)]];
    }
    return _rightArrow;
}
-(UILabel *)valueLab{
    if (!_valueLab) {
        _valueLab = [UILabel new];
        _valueLab.font = FONT_SYS14;
        _valueLab.textColor = COLOR_33;
    }
    return _valueLab;
}
-(void)reload:(ProductEditData*)data{
    _titleLab.text = data.title;
    if (data.dataKey) {
        _valueLab.text = [self.productData valueForKey:data.dataKey];
    }
    
}

-(void)layoutSubviews{
    [super layoutSubviews];
    [_titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.contentView).mas_offset(KPAND_DEF);
        make.centerY.mas_equalTo(self.contentView);
    }];
    
    [_notNullIcon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.titleLab.mas_right);
        make.centerY.mas_equalTo(self.contentView);
    }];
    [_valueLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(self.rightArrow).mas_offset(-KPAND_DEF);
        
        make.centerY.mas_equalTo(self.contentView);
    }];
    [_rightArrow mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(self.contentView).mas_offset(-KPAND_DEF);
        //        make.width.mas_equalTo(KAutoAcale(30));
        //        make.height.mas_equalTo(KAutoAcale(30));
        make.centerY.mas_equalTo(self.contentView);
    }];
}
@end
